package utils;

import org.junit.Test;

import java.io.*;

/**
 * @author chenshuyang
 */
public class CloneUtils implements ILogFactory {
    public static Object deepClone(Object o) throws Exception {
        try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
             ObjectOutputStream oos = new ObjectOutputStream(bos);) {
            oos.writeObject(o);
            try (ByteArrayInputStream basis = new ByteArrayInputStream(bos.toByteArray());
                 ObjectInputStream ois = new ObjectInputStream(basis);) {
                return ois.readObject();
            }
        }
    }
}